package com.ap.core.validation.message.rules;

import com.ap.core.cxf.jaxb.common.DeliveryInfoType;
import com.ap.core.cxf.jaxb.managertp.SubmitRTPMessageType;
import com.ap.core.message.managertp.info.SubmitRTPMessageInfo;
import com.ap.core.validation.message.info.MessageValidationInfo;
import com.ap.core.validation.message.info.OriginalInfo;
import com.ap.core.validation.rules.AbstractValidationRule;

/**
 * User: Somaraja.Surampudi The element <Delivery> is mandatory if the message
 * type is SUBMITRTPFORMOB, SUBMITRTPFORBRN
 */
public class IF0006Rule	extends 
                        AbstractValidationRule<MessageValidationInfo<SubmitRTPMessageInfo, OriginalInfo>> {

	@Override
	public boolean validate(
			MessageValidationInfo<SubmitRTPMessageInfo, OriginalInfo> infoObject) {
		final SubmitRTPMessageInfo submitRTPMessageInfo = infoObject
				.getBoundObject();

		SubmitRTPMessageType messageType = submitRTPMessageInfo.getMsgHdr().getMsgType();
		DeliveryInfoType delivery = submitRTPMessageInfo.getDelivery();

		if (SubmitRTPMessageType.SUBMITRTPFORMOB == messageType
				|| SubmitRTPMessageType.SUBMITRTPFORBRN == messageType) {

			return (null != delivery) ;
		}
		return true;
	}

}